package model;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectDB {
	public Connection getConnection(){
		Connection connection = null;
		String host = "jdbc:mysql://localhost/";
		String database = "myfilm";
		String unicode = "?setUnicode=true&characterEncoding=UTF-8";
		String url = host+database+unicode;
		String user = "root";
		String pass = "0123456";
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			connection = DriverManager.getConnection(url, user, pass);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("connect erro ... " + e.toString() );
		}
		return connection;
	}
	public static void main(String[] args) {
		ConnectDB con = new ConnectDB();
		System.out.println(con.getConnection());
	}
}
